//
//Copyright 2009 Google Inc.
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//
//
/**
 * @fileoverview This is a viewport viewer widget that displays the PDF in
 * rain viewer.
 */

/**
 * Creates a new viewport viewer. This viewer displays the PDF content in rain
 * viewer. It provides load function which enables reloading of PDF when div
 * size is changed. It is required that the HTML should have a div present with
 * the id viewportDivId, which is passed as an argument to this constructor.
 * @param {string} viewportDivId Identifier of the viewport div.
 * @param {string} url Viewport url.
 * @constructor
 */
digitalContentWizard.Viewport = function(viewportDivId, url) {
  /**
   * Dom id of the viewport div element.
   * @type {string}
   */
  this.viewportDivId = viewportDivId;
  /**
   * Url of the PDF to be shown.
   * @type {string}
   */
  this.url = url;
  /**
   * Viewport div element.
   * @type {HTMLElement}
   */
  this.viewportElement = document.getElementById(this.viewportDivId);
};

/**
 * Loads the viewport viewer within the specified div id.
 */
digitalContentWizard.Viewport.prototype.load = function() {
  var google = window['google'];
  var viewer = new google.books.DefaultViewer(
  this.viewportElement, {'showLinkChrome': false});
  viewer.load(this.url);
};
